<template>
    <div class="big-box">
        <div class="big-box-center">
            <div class="title">
                <div class="title-left">
                    <img :src="courseData.courseCover" class="title-img">
                </div>
                <div class="title-right">
                    <div class="title-text">
                        {{ courseData.courseTitle }}
                    </div>
                    <n-divider title-placement="left" style="color: black;margin-top: 0px;margin-bottom: 5px;">
                        <img src="/src/assets/svg/api-app.svg">
                    </n-divider>
                    <span style="font-size: 15px;font-family: '幼圆';">最近更新时间:{{ courseData.updateTime }}</span>
                    <div>
                        <p style="font-size: 16px;">简介：</p>
                        <p style="text-indent: 2em;">{{ courseData.courseIntro }}</p>
                    </div>
                </div>
            </div>

            <div class="list">
                <div class="list-top">
                    <span style="margin-left: 20px;font-size: 24px;">章节：</span>
                </div>
                <div class="list-data">
                    <div @click="$router.push({ name: 'ReadMd', params: { chapterId: item.chapterId } })" class="list-item"
                        v-for="(item, index) in courseData.chapterList" :key="index">
                       第 {{ index+1 }} 章：{{ item.title }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import { StarFilled } from "@element-plus/icons-vue";
import userHttp from '@/api/userHttp';
const props = defineProps(['courseId'])
const courseId = props.courseId
const courseData = ref({})
//初始化页面数据
onMounted(()=>{
    initCourseChapter()
})

//初始化课程章节数据
const initCourseChapter=()=>{
    userHttp.getCourseChapter(courseId).then((res)=>{
        if (res.code ==200) {
            console.log(res);
            courseData.value = res.data
            //时间去T
            courseData.value.updateTime = courseData.value.updateTime.replace("T", " ")
        }
    })
}
</script>

<style scoped>
.big-box {
    width: 100vw;
    background-size: cover;
    /*覆盖 */
    display: flex;
    justify-content: center;
}

.big-box-center {
    width: 85%;
    padding: 15px;
    border-radius: 20px;
    margin-top: 20px;
    background-color: rgba(250, 249, 249, 0.6);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    /* 增加阴影 */
}

.title {
    height: 300px;
    display: flex;
}

.title-left {
    flex: 3;
    height: 100%;
}

.title-right {
    flex: 7;
    height: 100%;
    margin-left: 10px;
    border-radius: 10px;
    padding: 10px;
    background-color: rgba(199, 206, 210, 0.5);
}

.title-img {
    border-radius: 10px;
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.title-text {
    font-family: "楷体";
    font-style: italic;
    font-size: 25px;
    text-shadow: 20px 20px 50px #6c7d4f;
    margin-bottom: 10px;
}

.list {
    margin-top: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.list-top {
    height: 50px;
    display: flex;
    align-items: center;
    border-top: 3px dotted rgb(236, 228, 228);
}

.list-data {
    overflow: auto;
    margin-bottom: 150px;
}

.list-item {
    height: 60px;
    display: flex;
    align-items: center;
    margin: 5px;
    border-radius: 10px;
    padding: 5px;
    cursor: pointer;
    border: 1px rgb(179, 179, 179, 0.6) solid;
    background-color: rgba(255, 255, 255, 0.5);
    transition: background-color 0.4s ease-in-out, border 0.8s ease-in-out;
    text-indent: 2em;
}

.list-item:hover {
    border: 1px rgb(62, 178, 0, 0.4) solid;
    background-color: rgba(211, 231, 222, 0.5);
}
</style>